<template>
	<view class="content">
		
		<view class="top-bg bacnone1">
			<!-- <text class="top-title">个人中心</text> -->
		</view>
		
		<view class="main_body ">
			<view class="top-card card-type">
				<!-- <image src="../../static/user_photo.png"></image> -->
				<view class="user-area" style="padding-left: 30rpx;">
					
					<view  v-if="isLogin == false"
						@click="navClick('../auth/gzhloin')"
					>点击进行登陆</view>
					<view v-else>
						<image :src="BaseInfo.HeadImg" class="avatar"  mode="widthFix">					
						</image>
						<view class="info-list">
							<text>用户名:{{BaseInfo.NickName}}</text>
							<!-- <text>账号:{{BaseInfo.Mobile}}</text> -->
						</view>
						
					</view>
				</view>
				<!-- <view   @click="navClick('mySetting/mySetting')">更改</view> -->
				
			
			</view>
			<view class="middle-card card-type">
				<view
					class="middle-item" 
					v-for="(item,index) in middleList"
					:key="index"
					@click="navClick(item.url)"
				>
					<view class="item-left">
						<image :src="item.imageUrl" style="width: 60rpx;" mode="widthFix"></image>
					</view>
					<view class="item-right">
						<view>
							<text>{{item.name}}</text>
						</view>
						<view>
							<u-icon size="30" name="arrow-right"></u-icon>
						</view>
					</view>
				</view>
				
			</view>
			<view class="middle-card card-type">
			
				<view
					class="middle-item" 
					v-for="(item,index) in nurseList"
					:key="index"
					@click="navClick(item.url)"
				>
					<view class="item-left">
						<image :src="item.imageUrl" style="width: 60rpx;" mode="widthFix"></image>
					</view>
					<view class="item-right">
						<view>
							<text>{{item.name}}</text>
						</view>
						<view>
							<u-icon size="30" name="arrow-right"></u-icon>
						</view>
					</view>
					
					
				</view>
			</view>
			
		</view>
		
		<view class="bottom_button" v-if="isLogin == true">
			
			<view>
				<!-- <u-button @click="logOut" :plain="true" type="primary" shape="circle">退出登录</u-button> -->
			</view>
			
		</view>
		
		
		
	</view>
</template>

<script>
	import { mapState, mapGetters, mapMutations } from 'vuex';
	import setter from '@/config.js';
	export default{
		data(){
			return{
				isNurse:0,
				isLogin:false,
				setter,
				BaseInfo:{
					HeadImg:'',
				},
				// 认证信息
				IdentityInfo: {
				    Type: 1,
				    IdentityStatus: 1,
				    IndustryId: '',
				    FullName: '',
				    CoTaxNo: '',
				    Person: '',
				    Mobile: '',
				    CardNo: '',
				    Province: '',
				    ProvinceId: '',
				    City: '',
				    CityId: '',
				    County: '',
				    CountyId: '',
				    Town: '',
				    TownId: '',
				    Address: '',
				    ContractArea: 0,
				    CardFrontImg: '',
				    CardBackImg: '',
				    CoLicenseImg: '',
				    IdentityReason: ''
				},
				badgeData: {
				    unreadMsg: 0
				},
				version: '1.0.0', //APP版本号
				user:{},
				userState:false,
				middleList:[
					// {
					// 	imageUrl:"/static/icon/xfjl.png",
					// 	name:"消费记录",
					// 	url:"middleFun/beNursed/beNursed?chooseFlag"
					// },
					{
						imageUrl:"/static/icon/ghjll.png",
						name:"挂号记录",
						url:"/pages/register/Scheduling/record/record"
					},
					// {
					// 	imageUrl:"/static/icon/ys.png",
					// 	name:"曾挂号医生",
					// 	url:"middleFun/collect/collect"
					// },
					// {
					// 	imageUrl:"/static/icon/zyjl.png",
					// 	name:"住院记录",
					// 	url:"middleFun/collect/collect"
					// }
					
				],
				nurseList:[
					{
						imageUrl:"/static/icon/gz.png",
						name:"关注的医生",
						url:"/pages/doctor/brscys"
					}
				]
				
			}
		},
		onLoad(){
			// #ifdef MP-WEIXIN
			this.version = wx.getAccountInfoSync().miniProgram.version || '1.0.0'; // 小程序 版本号
			// #endif
			
		},
		onShow() {
			if (this.hasLogin) {
			    this.$store.dispatch('getUserInfo');
				this.isNurse = this.$store.state.isnurse
				this.user = this.$store.state.userInfo
				this.userState = true
				this.isLogin = true
			    // this.totalMessage().then(res => {
			    //     this.badgeData.unreadMsg = res;
			    // });
			}
		},
		computed:{
			...mapState(['userInfo']),
			...mapGetters(['hasLogin', 'getUserInfo'])
	
		},
		watch:{
			userInfo(val) {
				
			    Object.assign(this.BaseInfo, val);
			    Object.assign(this.IdentityInfo, val.IdentityInfo);
				
			}
		},
		methods:{
			...mapMutations(['logout']),
			//退出
			logOut() {
			    let that = this;
			    that.$dialog.confirm('提示', '您确定要退出系统？').then(res => {
			        if (res) {
			            that.$dialog.loading('退出中...');
			            that.$request('auth', 'logout').then(() => {
			                that.$dialog.msg('退出成功', 500).then(() => {
			                    that.logout();
			                    uni.reLaunch({
			                        url: '/pages/index/index'
			                    });
			                });
			            });
			        }
			    });
			},
			
			navClick(url){
				
				if(url)
				{
					uni.navigateTo ({
						url,
						fail (error) {
						        console.log(error)
						    }
					})
				}
				else
				{
					this.show = true
				}
			
			}
			
		}
	}
</script>

<style>
	@import './My.css';
	
</style>